package com.ricky02;

import com.ricky02.EnableAnnotation.*;
import com.ricky02.condition.ConditionConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

import java.util.HashSet;
import java.util.Set;

@SpringBootApplication
@ComponentScan(basePackages = "com.ricky02")
@Import({User.class, EnableConfig.class, MyImportRegistry.class})
@EnableLog(name = "my ricky boot")
public class SpringBootStrat03 {
    public static void main(String[] args) {
        SpringApplication app=new SpringApplication();
        Set<Class<?>> set=new HashSet<>();
        set.add(SpringBootStrat03.class);
        app.addPrimarySources(set);
        ConfigurableApplicationContext run = app.run(args);

        System.out.println(run.getBeansOfType(ConditionConfig.class));
        System.out.println(run.getBean(User.class));
        System.out.println(run.getBean(User2.class));
        System.out.println(run.getBean(User3.class));

        run.close();
    }
}
